﻿@{
    ViewBag.Title = "ArtWorkGroup";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}


@section Header
{
    <script type="text/javascript">
        function openDialog(dialogName) {
            $('#' + dialogName).dialog('open');
            $('#' + dialogName + ' :text').val("");
            return false;
        }


        function deleteArtWorkGroup(groupName) {

            var artWorkGroup = { ArtWorkGroupName: groupName };

            $.post("/ArtWork/DeleteArtWorkGroup/", artWorkGroup,
                  function (data, textStatus) {
                      if (data == 'success') {
                          window.location.href = "/ArtWork/ArtWorkGroup/";
                      }
                      else { $.messager.alert('失败', data, 'error'); }
                  }
                );

        }

        function addArtWorkGroup() {
            //todo 验证重复输入



            if ($("#txt_ArtWorkGroup").validatebox('isValid') == false) { return; }


            //参数对象
            var artWorkGroup = { ArtWorkGroupName: $("#txt_ArtWorkGroup").val() };

            $.post("/ArtWork/AddArtWorkGroup/", artWorkGroup,
                    function (data, textStatus) {
                        if (data == 'success') {
                            $('#addArtWorkGroup').dialog('close');

                            window.location.href = "/ArtWork/ArtWorkGroup/";
                        }
                        else { $.messager.alert('失败', data, 'error'); }
                    }
                  );
        }


    </script>
}

<body>

    <p>
        <a id="btn" type="button" class="easyui-linkbutton" data-options="iconCls:'icon-add'" onclick="openDialog('addArtWorkGroup')">新增</a>
    </p>

    <div>
        <table style="width: 300px">

            <tr>
                <td>艺术家组名称</td>
                <td></td>
            </tr>
            @foreach (string item in ViewBag.ArtWorkGroup)
            {
                <tr>
                    <td>@item </td>
                    <td><a href="#" onclick="deleteArtWorkGroup('@item')">删除</a></td>
                </tr>    
            }
        </table>
    </div>



    @*隐藏层窗体*@
    <div id="addArtWorkGroup" class="easyui-dialog" title="新增艺术组" style="width: 350px; height: 300px;" modal="true" closed="true">
        艺术家组名称：<input id="txt_ArtWorkGroup" type="text" class="easyui-validatebox" required="true" />
        <br />
        <a href="#" onclick="addArtWorkGroup()">保存</a>
        <a href="#" onclick="$('#addArtWorkGroup').dialog('close'); return false;">取消</a>
    </div>



</body>
